﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace demo04a
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] b = new byte[128];
            string title, singer, album, year, comm;
            FileStream fs = new FileStream("D:\\Boy.mp3",FileMode.Open);
            fs.Seek(-128,SeekOrigin.End);
            fs.Read(b,0,128);
            bool isSet = false;
            string sFlag = System.Text.Encoding.Default.GetString(b,0,3);
            if (sFlag.CompareTo("TAG")==0)
            {
                Console.WriteLine("Tag is set");
                isSet = true;
            }

            if (isSet)
            {
                title = System.Text.Encoding.Default.GetString(b,3,30);
                Console.WriteLine(title);
                singer = System.Text.Encoding.Default.GetString(b,33,30);
                Console.WriteLine(singer);
                album = System.Text.Encoding.Default.GetString(b,63,30);
                Console.WriteLine(album);
                year = System.Text.Encoding.Default.GetString(b,93,4);
                Console.WriteLine(year);
                comm = System.Text.Encoding.Default.GetString(b,97,30);
                Console.WriteLine(comm);
            }
            Console.ReadLine();
        }
    }
}
